﻿<div ms-controller="TSGLLIST">
    <!-- 添加按钮 -->
    <div class="btn-add">
        <button type="button" class="btn btn-info btn-lg" ms-click="addJHSX()"><i class="iconfont icon-jiahao ft12 mr5"></i>添加计划科目</button>
        <!--<button type="button" class="btn btn-info btn-lg" ms-click="addJY"><i class="iconfont icon-jiahao ft12 mr5"></i></button>-->

    </div>
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜索计划科目名称">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display:none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 表格 -->

    <div class="default-tab ft14 pt20 grid">
        <div id="jqxgrid" style="border-right:0;border-left:0;"></div>

    </div>

    <div class="modal fade" id="DiaJHSX" role="dialog">
        <div class="modal-dialog" role="document" style="width: 500px">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">分类管理</h4>
                </div>
                <div class="modal-body">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="col-xs-4 control-label"><span class="Required " style="color:red">*</span>现金流方向</label>
                            <select class="form-control szhl_require" style="width:200px" ms-duplex="jhsx.FLType">
                                <option value="正">正</option>
                                <option value="负">负</option>

                            </select>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-4 control-label"><i>*</i> 上级属性ID</label>
                            <div class="col-xs-5" style="padding-right:0;padding-left:0">
                                <input type="text" disabled="disabled" class="form-control szhl_require disabled" style="width: 200px" placeholder="请选择上级" ms-duplex="jhsx.pid" />

                            </div>
                            <span class="input-group-addon" style="width:72px;height:34px;" ms-click="selsx()">选择上级</span>
                        </div>

                        <div class="form-group">
                            <label class="col-xs-4 control-label"><span class="Required " style="color:red">*</span>名称</label>
                            <input type="text" class="form-control szhl_require" style="width: 200px" placeholder="请填写名称" ms-duplex="jhsx.name" />
                        </div>

                        <div class="form-group" ms-if="jhsx.FLType=='负'">
                            <label class="col-xs-4 control-label"><span class="Required " style="color:red">*</span>付款级次</label>
                            <select class="form-control szhl_require" style="width:200px" ms-duplex="jhsx.fkjc" id="fkname">
                                <option value="">请选择付款级次</option>
                                <option ms-repeat-item="fkjcdata" ms-attr-value="item.ID">{{item.TypeName}}</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-success" id="conaddForder" ms-click="SaveJHSX()">确&nbsp;&nbsp;认</button>
                </div>
            </div>
        </div>
    </div>
</div>
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.base.css" />
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.office.css" />
<script src="/VIEWV5/JS/YanGrid/jqwidgets/jqgridall.js"></script>
<script>
    var goption = {
        columns: [
                {
                    text: '#', sortable: false, filterable: false, editable: false,
                    groupable: false, draggable: false, resizable: false,
                    datafield: '', columntype: 'number', width: 50,
                    cellsrenderer: function (row, column, value) {
                        return "<div style='margin:4px; margin-top: 15px;'>" + (value + 1) + "</div>";
                    }
                },
                { text: '科目ID', dataField: 'ID', width: "5%", hidden: "hides" },
                                { text: '科目代码', dataField: 'path', width: "5%" },

              { text: '名称', dataField: 'name', width: "20%" },
              { text: '现金流方向', dataField: 'FLType' },
               { text: '上级属性ID', dataField: 'pid' },
              { text: '付款级次', dataField: 'fkjcname' },
              { text: '创建时间', dataField: 'CRDate', editable: false },
               {
                   text: '操作', dataField: 'CRUser', width: "20%", cellsrenderer: function (row, column, value) {
                       var data = $('#jqxgrid').jqxGrid('getrowdata', row);
                       var intCZID = data.ID;
                       var html = "";
                       html = '<a href="#" onclick="tempindex.edit(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">编辑</p></a><a href="#" onclick="tempindex.del(\'' + intCZID + '\')"><p class="text-error" style="display: inline;margin-left: 20px;font-size: 16px;    color: Red;">删除</p></a>';
                       var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + html + '</div>';
                       return returns;
                   }
               },

        ]
    };
    var tempindex = avalon.define({
        $id: "TSGLLIST",
        tmpListData: [],
        jhsx: { pid: "-1", FLType: "正", name: "", fkjcname: "", fkjc: "" },
        fkjcdata: [],
        cz: function (row, column, value) {
            var data = $('#jqxgrid').jqxGrid('getrowdata', row);
            var intCZID = data.ID;
            var html = "";
            html = '<a href="#" onclick="tempindex.edit(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">编辑</p></a><a href="#" onclick="tempindex.del(\'' + intCZID + '\')"><p class="text-error" style="display: inline;margin-left: 20px;font-size: 16px;    color: Red;">删除</p></a>';
            var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + html + '</div>';
            return returns;

        },
        edit: function (row) {
            var data = $('#jqxgrid').jqxGrid('getrowdata', row);
            tempindex.jhsx = data;
            $("#DiaJHSX").modal('show');

        },
        del: function (id) {
            ComFunJS.winconfirm("确认要删除该项吗？", function () {
                $.post("/API/VIEWAPI.ashx?ACTION=JHZD_DELJHSXBYID", { P1: id }, function (jsonresult) {
                    if ($.trim(jsonresult.ErrorMsg) == "") {
                        tempindex.GetLIST();
                        ComFunJS.winsuccess("操作成功");
                    }
                });
            }, function () { })
        },
        GetLIST: function () {
            $('#jqxgrid').jqxGrid('destroy');
            $(".grid").append("<div id='jqxgrid' style='border-right:0;border-left:0;'></div>")
            $.getJSON('/API/VIEWAPI.ashx?Action=JHZD_GETJHSXLIST', { P1: model.search.searchcontent }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    ComFunJS.inithighgrid(goption, resultData.Result, "jqxgrid");
                }
            })


        },
        InitWigetData: function () {
            model.search.seartype = "";
            $.getJSON('/API/VIEWAPI.ashx?Action=JHZD_GETJHSXLIST', { P1: model.search.searchcontent }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    ComFunJS.inithighgrid(goption, resultData.Result, "jqxgrid");
                    tempindex.fkjcdata = resultData.Result1;
                }
            })
        },
        addJHSX: function () {
            $("#DiaJHSX").modal('show');

        },
        selsx: function () {
            var iszy = "Y";
            if (tempindex.jhsx.FLType == "负") {
                iszy = "N";
            }
            top.ComFunJS.winbtnwin("/ViewV5/AppPage/JHZD/JHSXSelect.html?iszf=" + iszy, "选择计划属性", 500, 470, {}, function (layero, index) {
                var frameid = $("iframe", $(layero)).attr('id');
                var datainfo = ComFunJS.isIE() ? top.window.frames[frameid].getselecteddata() : top.window.frames[frameid].contentWindow.getselecteddata();
                tempindex.jhsx.pid = datainfo.dataid;
                top.layer.close(index)
            })
        },
        SaveJHSX: function () {
            tempindex.jhsx.fkjcname = $('#fkname option:selected').text();
            $.post("/API/VIEWAPI.ashx?ACTION=JHZD_ADDJHSX", { P1: JSON.stringify(tempindex.jhsx.$model) }, function (jsonresult) {
                if ($.trim(jsonresult.ErrorMsg) == "") {
                    ComFunJS.winsuccess("操作成功");
                    $('#DiaJHSX').modal('hide');
                    tempindex.GetLIST();
                }
            });
        }
    })
    //@ sourceURL=JHSXLIST.js;
</script>
